﻿using System.Threading.Tasks;
using System.Collections.Generic;
using CustomLitJson;
using System;

public interface IChannel
{
    public Task InitIfNeedAsync();

    public Task<bool> PayOrAd(int payCount, string getItemName = null);

    public string GetNickname();
}

public abstract class Channel<T> : StuffObject<T>, IChannel where T : Channel<T>
{
    bool isInited;
    public async Task InitIfNeedAsync()
    {
        if(!isInited)
        {
            await this.OnInitAsync();
            isInited = true;
        }
    }

    public virtual async Task OnInitAsync()
    {
        await Task.FromResult(0);
    }

    public virtual async Task<bool> PayOrAd(int payCount, string getItemName)
    {
        await Task.FromResult(0);
        return false;
    }


    public virtual void OnLoginComplete()
    {

    }

    public virtual void OnLoginUserDataFetched()
    {

    }

    public virtual Task PurchaseAsync(int itemId)
    {
        throw new Exception("[Channel] Purchase not implement ");
    }

    public virtual string GetNickname()
    {
        throw new Exception("[Channel] GetNickname not implement ");
    }

    public virtual string GetAvatar()
    {
        throw new Exception("[Channel] GetAvatar not implement ");
    }

    public virtual void ReportLevel()
    {
        
    }

    public virtual void TrackEvent(string eventName, JsonData jd = null)
    {

    }

    public virtual bool IsPurchasingReaded
    {
        get
        {
            return true;
        }
    }

    public virtual bool IsAutoLogin
    {
        get
        {
            return false;
        }
    }

    public virtual bool IsSupportAd
    {
        get
        {
            return false;
        }
    }

    public virtual bool IsSupportPurchase
    {
        get
        {
            return false;
        }
    }
}
